﻿using System.Windows.Forms.Design;
using MySqlConnector;

namespace Front._1120;

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
    }

    private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
    {
        throw new System.NotImplementedException();
    }

    private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
    {
        throw new System.NotImplementedException();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        openFileDialog1 = new OpenFileDialog();
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            File.Copy(openFileDialog1.FileName,"D:\\1120\\"+Path.GetFileName(openFileDialog1.FileName));
        }
    }

    private void button3_Click(object sender, EventArgs e)
    {
        openFileDialog1 = new OpenFileDialog();
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            string path = openFileDialog1.FileName;
            string strFileName = Path.GetFileName(path);
            string uuid = Guid.NewGuid().ToString();
            long time = DateTime.Now.Ticks;
            File.Copy(openFileDialog1.FileName,"D:\\1120\\"+Path.GetFileName(openFileDialog1.FileName));
            this.pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
        }
        
    }
    private void button2_Click(object sender, EventArgs e)
    {
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            string str = "hello";
            File.WriteAllText(saveFileDialog1.FileName,str);
        }
    }

    private void button4_Click(object sender, EventArgs e)
    {
        using var connection = new MySqlConnection("server=localhost;port=3306;database=book;user=root;password=root;charset=utf8mb4;AllowPublicKeyRetrieval=True;");
        connection.Open();

        using var command = new MySqlCommand("SELECT * FROM book_info;", connection);
        using var reader = command.ExecuteReader();
        while (reader.Read())
            Console.WriteLine(reader.GetInt32(2));
    }
}